package top.infopub.enums.fia;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*月度资金计划--保证金支出类型*/
public enum BondOutTypeEnum {
    //保证金支出类型，1=投标保证金，2=履约保证金，3=履约保函费用，4=运营保函费用，5=移交保函费用，6=其他
    HAND_MODE1("1", "投标保证金"),
    HAND_MODE2("2", "履约保证金"),
    HAND_MODE3("3", "履约保函费用"),
    HAND_MODE4("4", "运营保函费用"),
    HAND_MODE5("5", "移交保函费用"),
    HAND_MODE8("6", "其他");

    private String code;

    private String name;

    BondOutTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static BondOutTypeEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (BondOutTypeEnum ite : BondOutTypeEnum.values()) {
            if (StringUtils.equals(code, ite.getCode())) {
                return ite;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (BondOutTypeEnum ite : BondOutTypeEnum.values()) {
            map = new HashMap<>();
            map.put("code", ite.getCode());
            map.put("name", ite.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
